package com.honestpeak.datafusion.web;

import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.honestpeak.datafusion.model.StaminaResult;
import com.honestpeak.datafusion.service.StaminaService;

import net.sf.json.JSONArray;

/**
 * @Auther: apple
 * @Date: 2018/8/11 15:18
 * @Description: 体测控制层
 */
@Controller
@RequestMapping("/stamina")
public class StaminaController {
	@Autowired
    private StaminaService staminaService;
	
	//根据学期或项目获取所有俱乐部的体质健康数据
	//体测数据界面：接口1
    @RequestMapping(value = "/getClubHealthByYearAndproject", method = RequestMethod.GET)
    @ResponseBody
    public Object getClubHealthByYearAndproject(Long yearTermId, Long projectId){
        List<StaminaResult> resultList = staminaService.getClubHealthByYearAndproject(yearTermId,projectId);
        return resultList;
    }
    
    //根据学期和俱乐部获取某个俱乐部的体质健康数据
    //体测数据界面：接口2
    @RequestMapping(value = "/getClubHealthByYearAndClubId", method = RequestMethod.GET)
    @ResponseBody
    public Object getClubHealthByYearAndClubId(Long yearTermId, Long clubId){
        List<StaminaResult> resultList = staminaService.getClubHealthByYearAndClubId(yearTermId,clubId);
        return resultList;
    }
    
    //根据学年获取所有系的体测数据
    //数据比较界面：各系体测数据接口
    @RequestMapping(value = "/getLevelNumByYear", method = RequestMethod.GET)
    @ResponseBody
    public Object getLevelNumByYear(Long year,String[] departNames){
        List<StaminaResult> resultList = staminaService.getLevelNumByYear(year, departNames);
        return resultList;
    }
    
    
    //学生个人数据界面：个人体测项目
    @RequestMapping(value = "/getMarkList", method = RequestMethod.GET)
    @ResponseBody
    public Object getMarkList(Long year, String studentNo){
    	Map<String, Object> map = staminaService.getMarkList(year, studentNo);
        return map;
    }
    
    //根据学年获取指定系指定班级的各项体测数据
    //学生班级数据界面：班级各项体测成绩分布接口
    @RequestMapping(value = "/getProjectLevelNum", method = RequestMethod.GET)
    @ResponseBody
    public Object getProjectLevelNum(Long yearTermId,Long departId, Long classId){
        List<StaminaResult> resultList = staminaService.getProjectLevelNum(yearTermId, departId, classId);
        String jsonString=JSONArray.fromObject(resultList).toString();
        System.out.println(jsonString);
        return resultList;
    }
}
